#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: multi_process.py 
@version:
@time: 2023/04/17 
"""

import concurrent.futures
import time
import requests


def download_one(url):
    resp = requests.get(url)
    print('Read {} from {}'.format(len(resp.content), url))


def download_all(sites):
    with concurrent.futures.ProcessPoolExecutor() as executor:
        executor.map(download_one, sites)


def main():
    sites = [
                'https://www.baidu.com',
            ] * 50
    start_time = time.perf_counter()
    download_all(sites)
    end_time = time.perf_counter()
    print('Download {} sites in {} seconds'.format(len(sites), end_time - start_time))


if __name__ == '__main__':
    main()
